<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>日历图热图</title>
	<script src="../static/js/echarts.js"></script>
	<!-- <script src="../static/js/echarts.min.js"></script> -->
</head>
<body>
	<div id="main" style="width: 100%;height:400px;"></div>
</body>
<script type="text/javascript">
// 基于准备好的dom，初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));

// 模拟数据
function getVirtulData(year) {
	year = year || '2017';
	var start = +echarts.number.parseDate(year + '-01-01');
	var end = +echarts.number.parseDate(year + '-12-31');
	var dayTime = 3600 * 24 * 1000;
	var data = [];
	for (var time = start; time <= end; time += dayTime) {
		data.push([
			echarts.time.format(time, '{yyyy}-{MM}-{dd}', false),
			Math.floor(Math.random() * 10000)
		]);
	}
	return data;
}
// console.log(echarts.format.formatTime('yyyy-MM-dd', 1689673264000));
// console.log(echarts.time.format(1689673264000, '{yyyy}-{MM}-{dd}'));

// 指定图表的配置项和数据
var option = {
	visualMap: {
		show: true,
		min: 0,
		max: 10000
	},
	calendar: {
		range: '2017'
	},
	series: {
		type: 'heatmap',
		coordinateSystem: 'calendar',
		data: getVirtulData(2017)
	}
};

// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);

// 处理点击事件并且跳转到相应的百度搜索页面
myChart.on('click', function (params) {
	// console.log(params);
	console.log(params.data);
});
</script>
</html>
